/*
package com.example.demo.controller;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;


@RestController
public class TestController {
    private RedisTemplate<String,String> redisTemplate;
    @Test
    public void testRedisString(){
        System.out.println(redisTemplate.opsForValue().get("pyx"));
    }
    @Test
    public void testRedisMap(){
        Map<String,String> mp = new HashMap<>();
        mp.put("张三","小三");
        mp.put("李四","小四");
        mp.put("马师爷","葛优");
        mp.put("张麻子","姜文");
        //redisTemplate.opsForHash().putAll("name",mp);//将map整个存入redis的Hash中(说是Hash，实际上是Map)
        //redisTemplate.opsForHash().put("name","school","hello");//单个存入,如果重复则覆盖
        //System.out.println(redisTemplate.opsForHash().values("name"));//取出name中的值
        //System.out.println(redisTemplate.opsForHash().putIfAbsent("name", "chool", "hello"));//单个存入数据，如果存在返回false，不覆盖，不存在插入后并返回true
        //System.out.println(redisTemplate.opsForHash().entries("name"));
        //redisTemplate.opsForHash().delete("name","school");//删除name中的school键值对
        //System.out.println(redisTemplate.opsForHash().entries("name"));
        //redisTemplate.opsForHash().put("name","123","123");
        //redisTemplate.opsForHash().put("name","123","456");//覆盖123
        //redisTemplate.opsForHash().putIfAbsent("name","123","123");//没有覆盖456
        //System.out.println(redisTemplate.opsForHash().entries("name"));
        //System.out.println(redisTemplate.opsForHash().scan("name", ScanOptions.scanOptions().match("123").build()));//按照正则表达式获取数据，返回一个游标
    }
    @Test
    public void testRedisList(){
        ArrayList<String> arrayList = new ArrayList<>();
        //redisTemplate.opsForList().leftPushAll("List",arrayList);
        //System.out.println(redisTemplate.opsForList().index("List",0));//这是一个队列，来得越晚离左边越近
        //System.out.println(redisTemplate.opsForList().range("List", 0, 1));//这是一个闭区间[l1,l2]；
        //redisTemplate.opsForList().rightPushAll("List",arrayList);//从尾部插入
        //redisTemplate.opsForList().leftPush("List","hello1");
        //redisTemplate.opsForList().leftPush("List","hello2");
        //redisTemplate.opsForList().leftPush("List","hello3");
        //redisTemplate.opsForList().leftPush("List","hello4");
        //redisTemplate.opsForList().leftPush("List","hello5");
        //System.out.println(redisTemplate.opsForList().range("List", 0, 5));
        //redisTemplate.opsForList().trim("List",1,4);//保留第1个到第4个之间的数据
        //System.out.println(redisTemplate.opsForList().range("List", 0, 5));
    }
    @Test
    public void testRedisSet(){//不可以对Hset直接使用set添加，但是可以对多个集合采用求交集，补集，并集
        Set<String> st1 = new HashSet<>();
        st1.add("123");
        st1.add("789");
        redisTemplate.opsForSet().add("set1","123");
        redisTemplate.opsForSet().add("set2","456");
        //redisTemplate.opsForSet().unionAndStore("set1","set2","set1");//将第一个与第二个求并集，并存入第三个
        redisTemplate.opsForSet().differenceAndStore("set1","set2","set1");//与上类似
        redisTemplate.opsForSet().differenceAndStore("set1",st1,"set1");
        Set<String> sts1 =  redisTemplate.opsForSet().members("set1");//获取set1的所有数据
        System.out.println(sts1.toString());
        Set<String> st = redisTemplate.opsForSet().difference("set2","set1"); //拿后一个与前一个比较，返回前一个有而后一个没有的数据
        System.out.println(st.toString());
    }
    @Test
    public void testRedisZSet(){//给每一个数据都附加一个double类型的分数，并以此实现排序
        redisTemplate.opsForZSet().add("Zset1","张麻子",1.00);
        redisTemplate.opsForZSet().add("Zset1","王二狗",1.00);
        redisTemplate.opsForZSet().add("Zset1","张麻子",2.00);
        System.out.println(redisTemplate.opsForZSet().zCard("Zset1"));//记录Zset当前大小
        System.out.println(redisTemplate.opsForZSet().rank("Zset1","王二狗"));//分数越小越靠前
    }
}
*/
